package com.fzf.org.config;

import com.fzf.org.dao.mapper.UserMapper;
import com.fzf.org.toolkit.RedisBloomFilterService;
import lombok.RequiredArgsConstructor;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@RequiredArgsConstructor
public class RedisBloomDataLoader implements CommandLineRunner {

    private final RedisBloomFilterService redisBloomFilterService;
    private final UserMapper userMapper;

    @Override
    public void run(String... args) throws Exception {
        List<String> accounts = userMapper.selectAllAccounts();
        for (String account : accounts) {
            redisBloomFilterService.addAccount(account);
        }
        System.out.println("布隆过滤器初始化完成，共加载账号数: " + accounts.size());
    }
}
